package com.xiaoh.dormitoryrepairreportbackend.model.dto.ai;

import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * AI分配结果
 */
@Data
public class AiAssignmentResult implements Serializable {
    
    /**
     * 是否成功分配
     */
    private boolean success;
    
    /**
     * 推荐的维修工ID
     */
    private Long recommendedMaintenanceId;
    
    /**
     * 推荐的维修工ID列表（按优先级排序）
     */
    private List<Long> candidateMaintenanceIds;
    
    /**
     * 分配原因/说明
     */
    private String reason;
    
    /**
     * 置信度（0-1）
     */
    private Double confidence;
    
    /**
     * 错误信息（如果分配失败）
     */
    private String errorMessage;
    
    private static final long serialVersionUID = 1L;
    
    /**
     * 创建成功的分配结果
     */
    public static AiAssignmentResult success(Long maintenanceId, String reason, Double confidence) {
        AiAssignmentResult result = new AiAssignmentResult();
        result.setSuccess(true);
        result.setRecommendedMaintenanceId(maintenanceId);
        result.setReason(reason);
        result.setConfidence(confidence);
        return result;
    }
    
    /**
     * 创建成功的分配结果（带候选列表）
     */
    public static AiAssignmentResult success(Long maintenanceId, List<Long> candidates, String reason, Double confidence) {
        AiAssignmentResult result = success(maintenanceId, reason, confidence);
        result.setCandidateMaintenanceIds(candidates);
        return result;
    }
    
    /**
     * 创建失败的分配结果
     */
    public static AiAssignmentResult failure(String errorMessage) {
        AiAssignmentResult result = new AiAssignmentResult();
        result.setSuccess(false);
        result.setErrorMessage(errorMessage);
        return result;
    }
}
